package com.geekaca.jsp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet(urlPatterns = "/test")
public class TestServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // todo: 访问这个servlet时，
        // 向request作用域中存入变量myName
        // 转发到jsp
        System.out.println("TestServlet service---------");
        req.setAttribute("myName", "dingo");
//        req.setAttribute("age", 23);
        HttpSession session = req.getSession();
//        session.setAttribute("age", 199);

        session.setAttribute("yourName","Tom");
        req.getRequestDispatcher("EL.jsp").forward(req, resp);


    }
}
